﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Kaiser.Domains;

namespace Kaiser.Repositories.Extension
{
    public interface IBaseDomainService {

        TEntity Get<TEntity>(long id) where TEntity : class, IDomain;

        void Add<TEntity>(TEntity entity) where TEntity : class, IDomain;

        void Modify<TEntity>(TEntity entity) where TEntity : class, IDomain;

        void Remove<TEntity>(TEntity entity) where TEntity : class, IDomain;

        void Remove<TEntity>(long id) where TEntity : class, IDomain;

        TEntity Single<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class, IDomain;

        IEnumerable<TEntity> GetAll<TEntity>()where TEntity : class, IDomain;

        IEnumerable<TEntity> GetAllMatching<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class, IDomain;

        IPagedDomainList<TEntity> GetPaged<TEntity, TProperty>(int pageIndex, int pageCount,Expression<Func<TEntity, TProperty>> orderByExpression,bool ascending)
            where TEntity : class, IDomain;

        IPagedDomainList<TEntity> GetPaged<TEntity, TProperty>(int pageIndex, int pageCount,
                                                               Expression<Func<TEntity, bool>> predicate,
                                                               Expression<Func<TEntity, TProperty>> orderByExpression,
                                                               bool @ascending)
            where TEntity : class, IDomain;

        IEnumerable<TEntity> GetFiltered<TEntity>(Expression<Func<TEntity, bool>> filter)where TEntity : class, IDomain;

        void Merge<TEntity>(TEntity persisted, TEntity current)where TEntity : class, IDomain;
    }
}
